Source for file SC_SendMail.php
Documentation is available at SC_SendMail.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(dirname(__FILE__ ) . '/../module/Mail.php');
require_once(dirname(__FILE__ ) . '/../module/Mail/mime.php');
$this->arrRecip = array();
$this->backend = MAIL_BACKEND;
mb_language( "Japanese" );
//-- PEAR::Mailを使ってメール送信オブジェクト作成
$this->objMail = & Mail::factory($this->backend,
$this->arrRecip[$key] = $recipient;
function setTo($to, $to_name = "") {
function setFrom($from, $from_name = "") {
function setCc($cc, $cc_name = "") {
$this->reply_to = $reply_to;
$this->subject = mb_encode_mimeheader($subject, "JIS", 'B', "\n");
$this->body = mb_convert_encoding($body, "JIS", CHAR_CODE);
//-- PEAR::Mailを使ってメール送信オブジェクト作成
$this->objMail = & Mail::factory("smtp", $arrHost);
//-- PEAR::Mailを使ってメール送信オブジェクト作成
$this->objMail = & Mail::factory("smtp", $arrHost);
// windowsでは文字化けするので使用しない。
// $_name = mb_convert_encoding($_name,"JIS",CHAR_CODE);
$_name = mb_encode_mimeheader($_name, "JIS", 'B', "\n");
$name_address = "\"". $_name . "\"<" . $mail_address . ">";
$name_address = $mail_address;
function setItem($to, $subject, $body, $fromaddress, $from_name, $reply_to= "", $return_path= "", $errors_to= "", $bcc= "", $cc = "") {
$this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc);
function setItemHtml($to, $subject, $body, $fromaddress, $from_name, $reply_to= "", $return_path= "", $errors_to= "", $bcc= "", $cc = "") {
$this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc);
$fromaddress -> 送信元のメールアドレス
$from_name -> 送信元の名前(全角OK)
$return_path -> return-pathアドレス設定(エラーメール返送用)
function setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to= "", $return_path= "", $errors_to= "", $bcc= "", $cc = "") {
// 本文設定(iso-2022-jpだと特殊文字が?で送信されるのでJISを使用する)
$this->setFrom($fromaddress, $from_name);
// Errors-Toは、ほとんどのSMTPで無視され、Return-Pathが優先されるためReturn_Pathに設定する。
} else if($return_path != "") {
$arrHeader['MIME-Version'] = '1.0';
$arrHeader['To'] = $this->to;
$arrHeader['Subject'] = $this->subject;
$arrHeader['From'] = $this->from;
if($this->reply_to != "") {
$arrHeader['Reply-To'] = $this->reply_to;
$arrHeader['Cc'] = $this->cc;
$arrHeader['Bcc'] = $this->bcc;
$arrHeader['Date'] = date("D, j M Y H:i:s O");
$arrHeader['Content-Type'] = "text/plain; charset=\"ISO-2022-JP\"";
$arrHeader['Content-Transfer-Encoding'] = "7bit";
$arrHeader['Content-Type'] = "text/html; charset=\"ISO-2022-JP\"";
$arrHeader['Content-Transfer-Encoding'] = "ISO-2022-JP";
switch ($this->backend) {
* 設定された情報を利用して, メールを送信する.
* メールの宛先に Cc や Bcc が設定されていた場合は, 宛先ごとに複数回送信を行う.
* - getRecip() 関数の返り値が配列の場合は, 返り値のメールアドレスごとに,
* PEAR::Mail::send() 関数を実行する.
* - getRecip() 関数の返り値が string の場合は, 返り値のメールアドレスを
* RCPT TO: に設定し, PEAR::Mail::send() 関数を実行する.
foreach ($recip as $rcpt_to) {
$results[] = $this->objMail->send($rcpt_to, $header, $this->body);
$results[] = $this->objMail->send($recip, $header, $this->body);
foreach ($results as $result) {
if (PEAR::isError($result)) {
GC_Utils_Ex::gfPrintLog($result->getMessage());
GC_Utils_Ex::gfDebugLog($header);
if (PEAR::isError($result)) {
GC_Utils_Ex::gfPrintLog($result->getMessage());
GC_Utils_Ex::gfDebugLog($header);
* メーラーバックエンドに応じたパラメータを返す.
* @param string $backend Pear::Mail のバックエンド
* @return array メーラーバックエンドに応じたパラメータの配列
$arrParams = array('sendmail_path' => '/usr/bin/sendmail',
Documentation generated on Fri, 24 Feb 2012 14:00:21 +0900 by Seasoft
|